<template>
  <div class="jfgl_box">
    <header-comm></header-comm>
    <div class="header_sele" :style="$parent.$parent.collapsed==false?'left: 10%':'left:80px'">
      <div class="add_qy">
        <!-- <a-button type="primary" @click="tjwz">添加文章</a-button>
        <a-button @click="start">批量删除</a-button>-->
      </div>
      <div>
        <!-- <div class="list_head">
          <div class="fl_right">
            <a-radio-group v-model="valuefl">
              <a-radio :value="1">私有询价</a-radio>
              <a-radio :value="2">云询价</a-radio>
            </a-radio-group>
          </div>
        </div> -->
        <div class="jfgl" v-if="$store.state.tjwz">
          <tjwzym class="jfgl_xgym"></tjwzym>
        </div>
        <div class="seach">
          <div class="sele">
            <a-input placeholder="请输入查询关键词 " style="width: 250px" @change="onSearch" />
            <a-icon type="search" class="search" />
          </div>
        </div>
      </div>
    </div>
    <!-- 表格-================= -->
    <div class="bcg">
      <div class="glwz">
        <!-- <xzl v-if="$store.state.xzlflg"></xzl> -->
        <a-table
          @change="handleChangelist"
          :loading="loading"
          :columns="columns"
          :pagination="pagination"
          :dataSource="data"
          :rowSelection="rowSelection"
        >
          <template v-for="titletext in []" :slot="titletext" slot-scope="text, record, index">
            <div :key="titletext"></div>
          </template>

          <!-- <template slot="operation" slot-scope="text, record, index">
            <div class="editable-row-operations">
              <a class="del" @click="()=>xiugai(record,record.key)">修改</a>
            </div>
          </template> -->
        </a-table>

      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
import headerComm from "../header-comm/header.vue";
import tjwzym from "../tjwz/tjwzym.vue";
// import xzl from "./xzl.vue";

const columns = [
  {
    title: "会员账号",
    dataIndex: "id_num"
  },
  {
    title: "会员名称",
    dataIndex: "title"
  },

  {
    title: "公司名称",
    dataIndex: "articleName"
  },

  {
    title: "+/-",
    dataIndex: "wzname"
  },
  {
    title: "时间",
    dataIndex: "datetime"
  },
  {
    title: "奖励说明",
    dataIndex: "zt"
  }
];
//上传图片
function getBase64(img, callback) {
  const reader = new FileReader();
  let file = [];
  file = reader;
  reader.addEventListener("load", () => callback(reader.result));
  reader.readAsDataURL(img);
  sessionStorage.setItem("file", reader);
}
const data = [];
export default {
  data() {
    this.cacheData = data.map(item => ({ ...item }));
    return {
      data,
      columns,
      serchvalue: "",
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0
      },
      loading: true,
      selectedRowKeys: [],
    };
  },
  components: {
    headerComm,
    tjwzym
    // xzl
  },
  methods: {
    //搜索框
    onSearch(e) {
      this.serchvalue = value;
      var value = e.target.value;
      console.log(e.target.value);
      this.handleChangelist(this.pagination, value);
    },

    //表格
    handleChangelist(pagination, khmc) {
      // const newData = [...this.data]
      // const target = newData.filter(item => key === item.key)[0]
      this.axios
        .post(
          "wenzhang/AdminArticleList.php",
          qs.stringify({
            page: pagination.current,
            pageSize: pagination.defaultPageSize,
            sqdwid: this.$store.state.bbl_sqdwid,
            title: khmc,
            articleClass: ""
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.data = res.data.result.data;
            this.pagination.total = Number(res.data.result.total);
            this.loading = false;
            this.cacheData = this.data.map(item => ({
              ...item
            }));
            for (var i = 0; i < res.data.result.data.length; i++) {
              this.data[i].key = res.data.result.data[i].id_num;
            }
          } else {
            this.data = [];
          }
        });
      // if (target) {
      //   target[column] = value
      // this.data=newData
      // }
    },
    xiugai(value, key) {
      console.log(value);
      this.$store.state.id_num = value.id_num;
      this.$store.state.title = value.title;
      this.$store.state.content = value.content;
      this.$store.state.articleClass = value.articleClass;
      this.$store.state.pushTime = value.datetime;
     

      this.$store.state.tjwz = true;
      this.$store.state.xiugaiflag = "123";
    },
    
    //文章分类列表
  },
  computed: {
    rowSelection() {
      const { selectedRowKeys } = this;

      return {
        onChange: (selectedRowKeys, selectedRows) => {
          console.log(
            `selectedRowKeys: ${selectedRowKeys}`,
            "selectedRows: ",
            selectedRows
          );
          this.selectedRowKeys = selectedRowKeys;
          console.log(this.selectedRowKeys);
        }
      };
    }
  },
  created() {
    this.handleChangelist(this.pagination);
  }
};
</script>

<style lang='less' scoped>
.jfgl_box {
    position: relative;
  .jfgl {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999999;
    height: 930px;
    .jfgl_xgym {
      position: absolute;
      width: 80%;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  .header_sele {
    position: absolute;
    top: 55px;
    left: 200px;
    z-index: 999;
    text-align: right;
    width: 90%;
    background-color: #fff;
    box-shadow: 5px 5px 5px #ccc;
    // height: 50px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    .seach {
      display: inline-block;
      .sele {
        position: relative;
        i {
          position: absolute;
          top: 10px;
          right: 8px;
        }
      }
    }
    .list_head {
      display: inline-block;
      .tit {
        font-size: 16px;
      }
      padding: 10px 15px;
      .fl_right {
        .margin {
          margin: 0 5px;
        }
        .xzl_btn:hover {
          border: 0 !important;
          color: #fff !important;
          background: #1890ff !important;
        }
      }
    }
  }
  .glwz {
    width: 98%;
    position: absolute;
    top: 147px;
    left: 1%;
    background-color: #fff;
    border: 1px solid #ccc;
    .ant-table-thead > tr,
    .ant-table-tbody > tr {
      height: 50px !important;
    }
    .del {
    }
  }

 
  .ant-spin-nested-loading > div > .ant-spin {
    top: 100px !important;
  }
  .del {
    padding-right: 15px;
    color: #40a9ff;
    cursor: pointer;
  }
  
}
</style>
